package com.core.controller.test;

import com.common.shiro.realm.CustomRealm;
import com.common.utils.JwtUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class ClearUserCache {

    @Resource private CustomRealm customRealm;

    @RequestMapping("/clearUserCache")
    public String clearUserCache(HttpServletRequest request) {
        String userName = JwtUtils.getUserNameByToken(request.getHeader(JwtUtils.TOKEN_HEADER));
        customRealm.clearUserCache(userName);
        return "ok";
    }
}
